﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using LGE;

namespace TileMapEditor
{
    public class ChangeSizeScreen : GameScreen
    {
        int x = 50;
        Button buttonUpH, buttonDownH, buttonUpW, buttonDownW;
        Vector2 center = new Vector2(Engine.viewport.Width, +Engine.viewport.Height) / 2;

        public ChangeSizeScreen()
            : base()
        {
        }

        public override void LoadContent()
        {
            buttonUpH = new Button(Engine.Load<Texture2D>("Arrow\\up"), center + new Vector2(2*x, -x));
            buttonDownH = new Button(Engine.Load<Texture2D>("Arrow\\down"), center + new Vector2(2 * x, x));
            buttonUpW = new Button(Engine.Load<Texture2D>("Arrow\\up"), center + new Vector2(-2 * x, -x));
            buttonDownW = new Button(Engine.Load<Texture2D>("Arrow\\down"), center + new Vector2(-2 * x, x));
        }

        public override void Update(GameTime gameTime)
        {
            if (Input.KeyPressed(Keys.Enter)) GameScreenManager.ChangeScreen(new EditScreen());
            if (buttonUpH.Clicked) Block.Height++;
            if (buttonDownH.Clicked) Block.Height--;
            if (buttonUpW.Clicked) Block.Width++;
            if (buttonDownW.Clicked) Block.Width--;
            if (Block.Width < 1) Block.Width = 1;
            if (Block.Height < 1) Block.Height = 1;
        }

        public override void Draw(GameTime gameTime, SpriteBatch sb)
        {
            buttonUpH.Draw(sb);
            buttonDownH.Draw(sb);
            buttonUpW.Draw(sb);
            buttonDownW.Draw(sb);
            sb.DrawString(TileMapEditor.Font, "Largura: " + Block.Width.ToString(), center - new Vector2(3*x, x/3), Color.Black);
            sb.DrawString(TileMapEditor.Font, "Altura: " + Block.Height.ToString(), center - new Vector2(-x, x/3), Color.Black);
        }
    }
}
